package com.yanu.meat.service.impl;

import com.yanu.meat.entity.SlaughterPigIn;
import com.yanu.meat.dao.SlaughterPigInDao;
import com.yanu.meat.service.SlaughterPigInService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (SlaughterPigIn)表服务实现类
 *
 * @author makejava
 * @since 2021-06-23 12:27:50
 */
@Service("slaughterPigInService")
public class SlaughterPigInServiceImpl implements SlaughterPigInService {
    @Resource
    private SlaughterPigInDao slaughterPigInDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public SlaughterPigIn queryById(Integer id) {
        return this.slaughterPigInDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<SlaughterPigIn> queryAllByLimit(int offset, int limit) {
        return this.slaughterPigInDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param slaughterPigIn 实例对象
     * @return 实例对象
     */
    @Override
    public SlaughterPigIn insert(SlaughterPigIn slaughterPigIn) {
        this.slaughterPigInDao.insert(slaughterPigIn);
        return slaughterPigIn;
    }

    /**
     * 修改数据
     *
     * @param slaughterPigIn 实例对象
     * @return 实例对象
     */
    @Override
    public SlaughterPigIn update(SlaughterPigIn slaughterPigIn) {
        this.slaughterPigInDao.update(slaughterPigIn);
        return this.queryById(slaughterPigIn.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.slaughterPigInDao.deleteById(id) > 0;
    }
}
